home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3193 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.1 KB

  1. Path: smis-sst-mg1-dip1-16.massey.ac.nz!user
  2. From: A.J.Norman@massey.ac.nz
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: keypress
  5. Date: 22 Jan 1996 19:50:43 GMT
  6. Organization: Massey University
  7. Message-ID: <A.J.Norman-2301960852530001@smis-sst-mg1-dip1-16.massey.ac.nz>
  8. References: <4dm5fr$2pi@prometheus.algonet.se>
  9. NNTP-Posting-Host: smis-sst-mg1-dip1-16.massey.ac.nz
  10.  
  11. In article <4dm5fr$2pi@prometheus.algonet.se>, Tkb@Algonet.Se (Johan
  12. Leikvik) wrote:
  13.  
  14. > Hi, I'm a beginner in c++ and I have  a little problem.. I wonder how
  15. > I read a key in a loop.. example: If I press the key 4 a variable
  16. > should increase.. But it shouldn't stop the program.. Please help me!
  17. > Yours:
  18. > Johan
  19.  
  20. I would suggest something along the following lines
  21.  
  22. while (!kbhit()&&(key==ReadKey())!=<quit key code)
  23.  if (key==<code of key 4>)
  24.    Variable++;
  25.  
  26. This is written using BC3.1.
  27.  
  28. Hope this gives you some ideas.
  29.  Andrew
  30.  
  31. -- 
  32. E-mail: A.J.Norman@massey.ac.nz
  33. "With the freedom of speech comes the freedom to be misunderstood"
  34. "When the going gets tough, the tough go on holiday"
  35. "Conserve ammo, watch your back and never deal with a dragon" - ShadowRunners comment on a blackened scorched wall.
  36.